package com.biz.primus.ms.commodity.dao.ro;

import com.biz.primus.base.redis.annotation.FieldSortedSet;
import com.biz.primus.base.redis.annotation.Ro;
import com.biz.primus.base.redis.bean.BaseRedisObject;
import com.biz.primus.commodity.vo.frontend.CascadeProductVo;
import com.biz.primus.common.utils.JsonUtils;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.List;

/**
 * 商品配置Ro
 *
 * @author david-liu
 * @date 2017年02月16日
 * @reviewer
 */
@Ro(key = "product:ProductCascadeRo")
public class ProductCascadeRo extends BaseRedisObject<Long> implements Serializable {
    private static final long serialVersionUID = -1413200852416402030L;

    /**
     * 分类ID
     */
    private Long categoryId;

    /**
     * 商家ID
     */
    private Long vendorId;

    /**
     * 配置名称
     */
    private String name;

    /**
     * 明细id以","分割
     */
    private String cascadeItemIds;

    /**
     * 配置的商品图(以JSON方式存放)
     */
    private String productExtendsMap;

    /**
     * 1.0结构
     */
    private String value;

    /**
     * 被配置商品id
     */
    @FieldSortedSet(key = "productCascadeId")
    private Long productCascadeId;

    public Long getProductCascadeId() {
        return productCascadeId;
    }

    public void setProductCascadeId(Long productCascadeId) {
        this.productCascadeId = productCascadeId;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public Long getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Long categoryId) {
        this.categoryId = categoryId;
    }

    public Long getVendorId() {
        return vendorId;
    }

    public void setVendorId(Long vendorId) {
        this.vendorId = vendorId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCascadeItemIds() {
        return cascadeItemIds;
    }

    public void setCascadeItemIds(String cascadeItemIds) {
        this.cascadeItemIds = cascadeItemIds;
    }

    public List<CascadeProductVo> getProductExtendsMap() {
        if (StringUtils.isBlank(productExtendsMap)) {
            return Lists.newArrayList();
        } else {
            return JsonUtils.json2Obj(productExtendsMap, List.class, CascadeProductVo.class);
        }
    }

    public void setProductExtendsMap(String productExtendsMap) {
        this.productExtendsMap = productExtendsMap;
    }

}
